/* Author      : Mark Kahn (cwolves@gmail.com)
 * Description : Parses an unlimited number of numeric, alpha, alphanumeric, hex or octal ranges into text.
 * 
 * Notes:
 * * Returns 1 copy of exactly what you send it for each replacement necessary. So if you want it to return 1 entry per line, make sure you select a linebreak when running this tool.
 * * You must download the javascript file from the google repository to your local machine
 * 
 * Command : cscript //NoLogo "c:\path to file\file.js"
 * Check   : "Run as text filter"
 * 
 * Example:
 * 
 * Input : [0x00-0x20] 
 * Output: 0 1 2 3 4 5 6 7 8 9 a b c d e f 10 11 12 13 14 15 16 17 18 19 1a 1b 1c 1d 1e 1f 20
 * 
 * Input : Option #[1-5][A-B], or reversed: [\1][\0]
 * Output:
 * Option #1A, or reversed: A1
 * Option #1B, or reversed: B1
 * Option #2A, or reversed: A2
 * Option #2B, or reversed: B2
 * Option #3A, or reversed: A3
 * Option #3B, or reversed: B3
 * Option #4A, or reversed: A4
 * Option #4B, or reversed: B4
 * Option #5A, or reversed: A5
 * Option #5B, or reversed: B5
 * 
 * Input : [ZX-102]
 * Output:
 * ZX
 * ZY
 * ZZ
 * 100
 * 101
 * 102
 */

var stdin   = WScript.StdIn;
var stdout  = WScript.StdOut;

Array.prototype.exists=function(e){return this.find(e)>=0;}
Array.prototype.find  =function(e){for(var i=0;i<this.length;i++)if(this[i]==e)return i;return -1;}

var input, results, matches;

var bases = [
	'0123456789ABCDEF',
	'01234567',
	'0123456789',
	'abcdefghijklmnopqrstuvwxyz',
	'ABCDEFGHIJKLMNOPQRSTUVWXYZ',
	'abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ',
	'0123456789abcdefghijklmnopqrstuvwxyz',
	'0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ',
	'0123456789abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ'
];

function baseToNum(str, base){
	var tbase = bases[base];
	var cnt   = tbase.length;
	var out   = 0;
	var zeros = tbase.substr(0, 1)=='0';
	if(!zeros) tbase = ' '+tbase;

	for(var i=0, j=str.length; i<j; i++){
		var dataVal = tbase.indexOf(str.charAt(i));
		out         = out * cnt + dataVal;
	}

	return out-(zeros?0:1);
}

function numToBase(num, base){
	var tbase = bases[base];
	var cnt   = tbase.length;
	var out   = '';
	var zeros = tbase.substr(0, 1)=='0';

	if(num==0) return tbase.substr(0, 1);

	if(zeros){
		while(num){
			out = tbase.substr(num % cnt, 1) + out;
			num = Math.floor(num / cnt);
		}
	} else {
		var root=1, check=1, check2=0, rttl = 0;
		while(num>=rttl){
			check2 = Math.pow(cnt, root++);
			out    = tbase.substr(Math.floor((num-rttl)/check)%cnt, 1) + out;
			check  = check2;
			rttl  += check;
		}
	}

	return out;
}

function getMode(str){
	if(str.length==0) return -1;
	if((str.indexOf('0x')==0) && /^[0-9A-F]+$/.test(str.substr(2))){                     return 0;
	}else if((str.indexOf('0')==0) && (str.length>1) && /^[0-7]+$/.test(str.substr(1))){ return 1;
	}else if(/^[0-9]+$/      .test(str)){                                                return 2;
	}else if(/^[a-z]+$/      .test(str)){                                                return 3;
	}else if(/^[A-Z]+$/      .test(str)){                                                return 4;
	}else if(/^[A-Za-z]+$/   .test(str)){                                                return 5;
	}else if(/^[a-z0-9]+$/   .test(str)){                                                return 6;
	}else if(/^[A-Z0-9]+$/   .test(str)){                                                return 7;
	}else if(/^[A-Za-z0-9]+$/.test(str)){                                                return 8;
	}
	return -1;
}

function strip(num){
	while((num.indexOf('0')==0)&&(num.length>1)) num=num.substr(1);
	if   ((num.indexOf('x')==0)&&(num.length>1)) num=num.substr(1);
	return num;
}

function decNumber(num, mode){
	switch(mode){
		case 0: return parseInt(strip(num), 16); break;
		case 1: return parseInt(strip(num), 8);  break;
		case 2: return eval(strip(num));         break;
		case 3: return baseToNum(num, 3);        break;
		case 4: return baseToNum(num, 4);        break;
		case 5: return baseToNum(num, 5);        break;
		case 6: return parseInt(num, 36);        break;
		case 7: return parseInt(num, 36);        break;
		case 8: return baseToNum(num, 8);        break;
	}
}

function modeNumber(num, mode){
	switch(mode){
		case 0: return num.toString(16);               break;
		case 1: return num.toString(8);                break;
		case 2: return num;                            break;
		case 3: return numToBase(num, 3);              break;
		case 4: return numToBase(num, 4);              break;
		case 5: return numToBase(num, 5);              break;
		case 6: return num.toString(36);               break;
		case 7: return num.toString(36).toUpperCase(); break;
		case 8: return numToBase(num, 8);              break;
	}
}

function readMode(str1, str2){
	var mode1 = getMode(str1);
	var mode2 = getMode(str2);
	if((mode1==-1)||(mode2==-1)) return -1;
	mode  = mode1>mode2?mode1:mode2;
	if(mode>1){
		var lc = [3,5,6,8].exists(mode1)||[3,5,6,8].exists(mode2);
		var uc = [4,5,7,8].exists(mode1)||[4,5,7,8].exists(mode2);
		var nm = [2,6,7,8].exists(mode1)||[2,6,7,8].exists(mode2);

		mode = lc?uc?nm?8:5:nm?6:3:uc?nm?7:4:nm?2:1;
		if(mode==-1) return;
	}

	i1    = decNumber(str1, mode);
	i2    = decNumber(str2, mode);

	return {mode:mode, start:i1, end:i2};
}

function parseData(input, depth){
	var out = '';
	var rx  = /(\[(&?[0-9A-Za-z]+)-(&?[0-9A-Za-z]+)\])/gi;
	var rx2 = /(\[(&?[0-9A-Za-z]+)-(&?[0-9A-Za-z]+)\])/gi;
	if(!rx.test(input)) return input;

	var matches = rx2.exec(input);
	var match   = matches[1];
	var start   = matches[2];
	var end     = matches[3];

	var sett    = readMode(start, end);

	for(var i=sett.start, j=sett.end; i<=j; i++){
		var mn = modeNumber(i, sett.mode);
		out+=parseData(input.replace(match, mn).replace(new RegExp('\\[\\\\'+depth+'\\]', 'g'), mn), depth+1);
	}
	return out;
}

stdout.Write(parseData(stdin.ReadAll(), 0));